/**
 * @file exercise_7_10.c
 * @author liangwenhao (1943080020@qq.com)
 * @brief 
 * @version 0.1
 * @date 2021-07-23
 * 
 * @copyright Copyright (c) 2021
 * 
 * @authorGitee  https://gitee.com/liangwenhao
 * @authorGithub https://github.com/WHaoL
 * @authorBlogs https://blog.csdn.net/liangwenhao1108
 *  
 * @Code Description: P180习题7.10找出代码中的错误  答案在P742 
 *  
 */

#include <stdio.h>
int
f1(int val)
{
	int		num = 0;
	int		*ptr = &num;

	if (val == 0) {
		int		val;

		val = 5;
		ptr = &val; //自动变量/局部变量val在"}"之后就已经不存在了，通过ptr指向val是错误的操作。
	}
	return(*ptr + 1);
}

int main()
{
    printf("%d\n",f1(0));
    printf("%d\n",f1(20));

    return 0;
}